const { doCreateTray } = require('../../biz/trayService/doCreateTray')
const { doDestroyTray } = require('../../biz/trayService/doDestroyTray')
const { doHideTrayWin } = require('../../biz/trayService/doHideTrayWin')




const { Tray } = require('electron')
const fileUtil = require("../../common/utils/fileUtil")
const EnvContext = require('../../common/context/EnvContext');

let tray = null
let foldIcon = fileUtil.getResoucePath("/icons/fold@3x.png")
let expandIcon = fileUtil.getResoucePath("/icons/expand@3x.png")

exports.bizTray = function () {
    tray = new Tray(foldIcon)
    tray.on('click', function () {
        const status = EnvContext.getInstance().getTrayStatus()
        if (status) {
            doDestroyTray()
            doHideTrayWin()
            tray.setImage(foldIcon)

        } else {
            doCreateTray()
            tray.setImage(expandIcon)
        }
        EnvContext.getInstance().setTrayStatus(!status)
    })
}



